/*
 * @Author: 小蜜蜂 84537795@qq.com
 * @Date: 2022-06-08 11:48:17
 * @LastEditTime: 2023-08-24 12:25:38
 * @LastEditors: 小蜜蜂 84537795@qq.com
 * @Description: 
 * @FilePath: /handheld-terminal-app/lib/main.dart
 * @CopyRight：小蜜蜂🐝  QQ：834537795
 */
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:material_collection_app/pages/splash_page.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:material_collection_app/routes/routes.dart';
import 'package:material_collection_app/utils/color.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

void main() {
  runApp(new MyApp());

  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);

  if (Platform.isAndroid) {
    // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后，是为了在渲染后进行set赋值，覆盖状态栏，写在渲染之前MaterialApp组件会覆盖掉这个值。
    SystemUiOverlayStyle systemUiOverlayStyle =
        SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }
}

final botToastBuilder = BotToastInit();
final easyload = EasyLoading.init();

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: '移动采集终端',
      builder: (context, child) {
        child = botToastBuilder(context, child);
        child = easyload(context, child);
        return child;
      },
      navigatorObservers: [BotToastNavigatorObserver()],
      theme: ThemeData(
        primarySwatch: createMaterialColor(Color(0xFFeeeeee)),
        primaryColor: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: SplashPage(),
      initialRoute: '/',
      onGenerateRoute: onGenerateRoute,
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: [
        const Locale('zh', 'CN'),
        const Locale('en', 'US'),
      ],
    );
  }
}
